package com.ruoyi.scenery.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.scenery.domain.SceneryData;
import com.ruoyi.scenery.service.ISceneryDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 景点信息管理Controller
 * 
 * @author ruoyi
 * @date 2023-04-09
 */
@RestController
@RequestMapping("/scenery/data")
public class SceneryDataController extends BaseController
{
    @Autowired
    private ISceneryDataService sceneryDataService;

    /**
     * 查询景点信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('scenery:data:list')")
    @GetMapping("/list")
    public TableDataInfo list(SceneryData sceneryData)
    {
        startPage();
        List<SceneryData> list = sceneryDataService.selectSceneryDataList(sceneryData);
        return getDataTable(list);
    }

    /**
     * 导出景点信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('scenery:data:export')")
    @Log(title = "景点信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SceneryData sceneryData)
    {
        List<SceneryData> list = sceneryDataService.selectSceneryDataList(sceneryData);
        ExcelUtil<SceneryData> util = new ExcelUtil<SceneryData>(SceneryData.class);
        util.exportExcel(response, list, "景点信息管理数据");
    }

    /**
     * 获取景点信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('scenery:data:query')")
    @GetMapping(value = "/{sceneryId}")
    public AjaxResult getInfo(@PathVariable("sceneryId") Long sceneryId)
    {
        return success(sceneryDataService.selectSceneryDataBySceneryId(sceneryId));
    }

    /**
     * 新增景点信息管理
     */
    @PreAuthorize("@ss.hasPermi('scenery:data:add')")
    @Log(title = "景点信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SceneryData sceneryData)
    {
        return toAjax(sceneryDataService.insertSceneryData(sceneryData));
    }

    /**
     * 修改景点信息管理
     */
    @PreAuthorize("@ss.hasPermi('scenery:data:edit')")
    @Log(title = "景点信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SceneryData sceneryData)
    {
        return toAjax(sceneryDataService.updateSceneryData(sceneryData));
    }

    /**
     * 删除景点信息管理
     */
    @PreAuthorize("@ss.hasPermi('scenery:data:remove')")
    @Log(title = "景点信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sceneryIds}")
    public AjaxResult remove(@PathVariable Long[] sceneryIds)
    {
        return toAjax(sceneryDataService.deleteSceneryDataBySceneryIds(sceneryIds));
    }
}
